const db = uniCloud.database()
exports.get = async (data) => {
  // 数据没有限制，表中有什么返回什么
  const collection = db.collection('pcimage')
  const res = await collection.count()

  // 查找最后一定要 get 一下
  let pageNum = data.page - 1
  let num = data.num
  if (!pageNum && !num) {
    const res1 = await collection.get()
    return [res, res1]
    // Promise.all([collection.get(), collection.count()]).then(result => {
    //   console.log(result[0], 123123);
    // return result[0]
    // })
  } else {
    const res2 = await collection.skip(pageNum * num).limit(num).get()
    return [res, res2]
  }
}
